import 'package:hive/hive.dart';

part 'comment.g.dart';

@HiveType(typeId: 2)
class CommentEntity extends HiveObject {
  @HiveField(0)
  final String id;

  @HiveField(1)
  final String content;

  @HiveField(2)
  final String userId;

  @HiveField(3)
  final String date;

  CommentEntity({
    required this.id,
    required this.content,
    required this.userId,
    required this.date,
  });

  factory CommentEntity.fromJson(Map<String, dynamic> json) {
    return CommentEntity(
      id: json['id'] as String,
      content: json['content'] as String,
      userId: json['userId'] as String,
      date: json['date'] as String,
    );
  }

  Map<String, dynamic> toJson() {
    return {'id': id, 'content': content, 'userId': userId, 'date': date};
  }

  CommentEntity copyWith({
    String? id,
    String? content,
    String? userId,
    String? date,
  }) {
    return CommentEntity(
      id: id ?? this.id,
      content: content ?? this.content,
      userId: userId ?? this.userId,
      date: date ?? this.date,
    );
  }

  @override
  String toString() {
    return 'CommentEntity(id: $id, content: $content, userId: $userId, date: $date)';
  }
}

final List<CommentEntity> sampleComments = [
  CommentEntity(
    id: 'c1',
    content: 'That\'s so beautiful!',
    userId: '2',
    date: '2024-04-23 09:20:15',
  ),
  CommentEntity(
    id: 'c2',
    content: 'I love this positive energy',
    userId: '3',
    date: '2024-04-23 10:45:32',
  ),

  CommentEntity(
    id: 'c3',
    content: 'I feel you',
    userId: '1',
    date: '2024-04-22 20:15:42',
  ),
  CommentEntity(
    id: 'c4',
    content: 'Take your time, you\'ll find your way',
    userId: '3',
    date: '2024-04-22 21:30:18',
  ),

  CommentEntity(
    id: 'c5',
    content: 'So peaceful',
    userId: '2',
    date: '2024-04-21 15:45:23',
  ),
  CommentEntity(
    id: 'c6',
    content: 'Rain has that effect',
    userId: '3',
    date: '2024-04-21 16:12:07',
  ),

  CommentEntity(
    id: 'c7',
    content: 'Start small',
    userId: '1',
    date: '2024-04-20 12:45:33',
  ),
  CommentEntity(
    id: 'c8',
    content: 'Practice makes perfect',
    userId: '3',
    date: '2024-04-20 14:22:51',
  ),

  CommentEntity(
    id: 'c9',
    content: 'Congratulations!',
    userId: '1',
    date: '2024-04-19 17:30:45',
  ),
  CommentEntity(
    id: 'c10',
    content: 'You deserve it!',
    userId: '2',
    date: '2024-04-19 18:15:22',
  ),
  CommentEntity(
    id: 'c11',
    content: 'Inspiring!',
    userId: '1',
    date: '2024-04-19 19:42:18',
  ),

  CommentEntity(
    id: 'c12',
    content: 'We all make mistakes',
    userId: '1',
    date: '2024-04-18 10:25:37',
  ),
  CommentEntity(
    id: 'c13',
    content: 'Try meditation',
    userId: '3',
    date: '2024-04-18 11:48:29',
  ),

  CommentEntity(
    id: 'c14',
    content: 'Self-care is important',
    userId: '2',
    date: '2024-04-17 16:33:41',
  ),
  CommentEntity(
    id: 'c15',
    content: 'Nature heals',
    userId: '3',
    date: '2024-04-17 17:55:16',
  ),

  CommentEntity(
    id: 'c16',
    content: 'Hang in there',
    userId: '1',
    date: '2024-04-16 21:20:44',
  ),
  CommentEntity(
    id: 'c17',
    content: 'Progress isn\'t always visible',
    userId: '3',
    date: '2024-04-16 22:15:33',
  ),

  CommentEntity(
    id: 'c18',
    content: 'So true!',
    userId: '2',
    date: '2024-04-15 13:25:52',
  ),
  CommentEntity(
    id: 'c19',
    content: 'Kindness matters',
    userId: '3',
    date: '2024-04-15 14:40:18',
  ),
  CommentEntity(
    id: 'c20',
    content: 'Made me smile',
    userId: '2',
    date: '2024-04-15 15:12:35',
  ),

  CommentEntity(
    id: 'c21',
    content: 'Keep going!',
    userId: '1',
    date: '2024-04-14 18:45:22',
  ),
  CommentEntity(
    id: 'c22',
    content: 'Every step counts',
    userId: '2',
    date: '2024-04-14 19:30:47',
  ),
  CommentEntity(
    id: 'c23',
    content: 'You\'re doing great',
    userId: '1',
    date: '2024-04-14 20:15:33',
  ),
];

List<CommentEntity> getAllComments() {
  return sampleComments;
}
